#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from datetime import datetime
from email.policy import default
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, DateTime, Enum, Text
from sqlalchemy.orm import relationship
from sqlalchemy.dialects.mysql import INTEGER
from db.database import Base
from common.utils import formatter

class XClass(Base):
    __tablename__ = 'class'

    class_id = Column(INTEGER(11), primary_key=True)
    name = Column(String(255), nullable=False)
    department = Column(String(255))
    grade = Column(String(255))
    major = Column(String(255))

    def __init__(self, name, department, grade,major):
        self.name = name
        self.department = department
        self.grade = grade
        self.major = major

    def __repr__(self):
        return 'Class:%s' % self.class_id

    def to_dict(self):
        new_dict = {}
        for c in self.__table__.columns:
            new_dict[formatter(c.name)] = getattr(self, c.name, None)
        return new_dict
